package algorithm.poj.p1000;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLDecoder;

public class P1730 {

	@SuppressWarnings("unchecked")
	public static void main(String[] args) throws Exception {

		InputStream input = null;
		if (false) {
			input = System.in;
		} else {
			URL url = P1730.class.getResource("P1730.txt");
			File file = new File(URLDecoder.decode(url.getPath(), "UTF-8"));
			input = new FileInputStream(file);
		}
		
		BufferedReader stdin = new BufferedReader(new InputStreamReader(input));

		int[] ps = primes(1<<16);
		String line = stdin.readLine();
		while (line != null && !"0".equals(line)) {
			long x = Long.valueOf(line.trim());
			int sign = 1;
			if (x < 0) {
				sign = -1;
				x = -x;
			}
			int[][] fs = factors(x, ps);
			int p = fs[0][1];
			for (int i = 1; i < fs.length; i ++) {
				p = (int)gcd(p, fs[i][1]);
			}
			if (sign == -1) {
				while (p%2 == 0) p /= 2;
			}
			System.out.println(p);
			line = stdin.readLine();
		}
	}
	
	public static int[] primes(int m) {
		
		if (m <= 1) {
			return new int[0];
		} else if (m == 2) {
			return new int[] {2};
		} else {
			int count = 0;
			int[] ns = new int[m];
			for (int i = 0; i < m; i ++) ns[i] = i;
			ns[0] = ns[1] = 0;
			
			int index = 2;
			int p = 0;
			while (index < m) {
				if (ns[index] != 0) {
					count ++;
					p = index;
					for (int j = (p<<1); j < m; j += p) {
						ns[j] = 0;
					}
				}
				index ++;
			}
			
			index = 0;
			int[] ps = new int[count];
			for (int i = 0; i < m; i ++) {
				if (ns[i] != 0) {
					ps[index ++] = i;
				}
			}

			return ps;
		}
	}

	public static int[][] factors(long n, int[] ps) {

		int[] as = new int[ps.length];
		for (int i = 0; i < as.length; i ++) {
			if (n >= ps[i]) {
				while (n%ps[i] == 0) {
					n /= ps[i];
					as[i] ++;
				}
			}
		}
		
		int count = 0;
		for (int i = 0; i < as.length; i ++) {
			if (as[i] > 0) {
				count ++;
			}
		}
		if (n > 1) count ++;
		
		int[][] fs = new int[count][];
		int index = 0;
		for (int i = 0; i < as.length; i ++) {
			if (as[i] > 0) {
				fs[index] = new int[2];
				fs[index][0] = ps[i];
				fs[index][1] = as[i];
				index ++;
			}
		}
		if (n > 1) {
			fs[count-1] = new int[2];
			fs[count-1][0] = (int)n;
			fs[count-1][1] = 1;
		}
		return fs;
	}

	public static long gcd(long x, long y) {

		x = (x<0)?(-x):x;
		y = (y<0)?(-y):y;
		if (x == 0) {
			return y;
		} else if (y == 0) {
			return x;
		} else {
			if (x < y) return gcd(y, x);
			else return gcd(y, x%y);
		}
	}
}